let nums = [7,2,11,15], target = 9

function twoSum(nums, target){
    const hash = new Map();
    for(let i = 0; i < nums.length; i++){
        const complement = target - nums[i];
        if(hash.has(complement)){
            return [hash.get(complement), i];
        }else{
            hash.set(nums[i], i)
        }
    }
}

console.log(twoSum(nums, target))